[bits 16]
; DESCRIPTOR(base, limit, access, grant)
%MACRO DESCRIPTOR 0-4 0, 0, 0, 0
	limit_low 	DW %2 & 0FFFFh
	base_low 	DW %1 & 0FFFFh
	base_mid	DB (%1 >> 16) & 0FFh
	access		DB %3
	limit_high	DB ((%2 >> 16) & 0FFh) | ((%4 << 4) & 0F0h)
	base_high  	DB (%1 >> 24) & 0FFh
%ENDMACRO


struc Descriptor
	.limit_low: resw 1
	.base_low: resw 1
	.base_mid: resb 1
	.access: resb 1
	.limit_height: resb 1
	; .flags: resd 1
	.base_height: resb 1
endStruc

GDT_START:
	; DESCRIPTOR_NULL: istruc Descriptor
		dq 0
	; iend
	DESCRIPTOR_CODE: istruc Descriptor
		at Descriptor.limit_low, 	dw 0xffff
		at Descriptor.base_low, 	dw 0
		at Descriptor.base_mid, 	db 0
		at Descriptor.access, 		db 0x9a
		at Descriptor.limit_height, db 11001111b
		at Descriptor.base_height, 	db 0
	iend
	DESCRIPTOR_DATA: istruc Descriptor
		at Descriptor.limit_low, 	dw 0xffff
		at Descriptor.base_low, 	dw 0
		at Descriptor.base_mid, 	db 0
		at Descriptor.access, 		db 0x92
		at Descriptor.limit_height, db 11001111b
		at Descriptor.base_height, 	db 0
	iend
GDT_LOC:
	dw GDT_LOC - GDT_START - 1
	dq GDT_START

LoadGDT:
	lgdt [GDT_LOC]
	ret